import multiprocessing  # 多进程
import time

def tack(i):
    print(f"任务{i}开始")
    time.sleep(i)
    print(f"任务{i}结束")
    return i



if __name__ == "__main__":
    lis = []
    start = time.time()
    for i in range(1,3):
        t = multiprocessing.Process(target=tack,args=(i,))
        t.start()
        lis.append(t)

    for i in lis:
        i.join()

    print(time.time()-start)  # 三个任务总耗时3秒
